package com.frank.oss.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2024/2/1 09:58
 * @description Minio 配置类
 */
@Configuration
public class MinioConfig {

    /**
     * Minio url
     */
    @Value("${spring.storage.minio.url}")
    private String url;

    /**
     * Minio access key
     */
    @Value("${spring.storage.minio.accessKey}")
    private String accessKey;

    /**
     * Minio secret key
     */
    @Value("${spring.storage.minio.secretKey}")
    private String secretKey;

    /**
     * 构造 Minio Client
     */
    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(url)
                .credentials(accessKey, secretKey)
                .build();
    }
}
